package ws.very.util.lang;

import java.util.HashMap;
import java.util.Map;

public class Maps {
	public static Map emptyHashMap = new HashMap();

	public static <K, V> V getOrDefault(Map<K, V> map, K key, V defaul) {
		V val = map.get(key);
		if (val == null)
			return defaul;
		else
			return val;
	}

	public static <K, V> V getOrUpdate(Map<K, V> map, K key, V update) {
		V val = getOrDefault(map, key, update);
		map.put(key, val);
		return val;
	}
}
